package com.xbts.web.controller.cloud;

import com.huaweicloud.sdk.vpc.v3.model.BatchCreateSecurityGroupRulesRequest;
import com.huaweicloud.sdk.vpc.v3.model.BatchCreateSecurityGroupRulesResponse;
import com.xbts.common.core.controller.BaseController;
import com.xbts.common.core.domain.AjaxResult;
import com.xbts.system.domain.dto.RegionIdDTO;
import com.xbts.system.service.ICloudServiceV3Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cloud/v3")
public class CloudServiceV3Controller extends BaseController {

    @Autowired
    private ICloudServiceV3Service cloudServiceV3Service;


    /**
     * https://support.huaweicloud.com/api-vpc/BatchCreateSecurityGroupRules.html
     * 批量创建安全组规则
     * @return 批量创建安全组规则
     */
    @PostMapping("/batchCreateSecurityGroupRules")
    public AjaxResult batchCreateSecurityGroupRules(@RequestBody RegionIdDTO<BatchCreateSecurityGroupRulesRequest> regionIdDTO) {
        BatchCreateSecurityGroupRulesResponse response = cloudServiceV3Service.batchCreateSecurityGroupRules(regionIdDTO);
        if (null == response){
            return error("批量创建安全组规则失败！");
        }
        return success(response);
    }

}
